package com.njwb.controller;

import com.njwb.pojo.Dept;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

//@Controller
//@ResponseBody
@RestController
public class AjaxController {
    @GetMapping("checkUserName")
    public  String checkUserName(@RequestParam("userName") String userName){
        int i = 1/0;
        if("sa".equals(userName)){
            return "1";
        }else{
            return "0";
        }
    }

    @GetMapping("getDepts")
    public  List<Dept> getDepts(){
        Dept d1 = new Dept();
        d1.setDeptNo(10);
        d1.setDname("研发部");
        d1.setLoc("L101室");
        Dept d2 = new Dept();
        d2.setDeptNo(20);
        d2.setDname("测试部");
        d2.setLoc("L102室");
        return Arrays.asList(d1,d2);
    }
}
